#include <unistd.h>
#include <stdio.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <fcntl.h>

typedef struct{
	int integer;
	char string[24];
} RECORD;

#define NRECORDS 100

int main()
{
	int f;
	RECORD *mapped;

	f = open("records.dat", O_RDWR);
	mapped = (RECORD *)mmap(0, NRECORDS*sizeof(RECORD), PROT_READ, MAP_SHARED, f, 0);

	while (getchar() != 'q')
	{
		printf("integer: %d, string: %s", mapped[43].integer, mapped[43].string);
	}
	munmap((void*)mapped, NRECORDS*sizeof(RECORD));
	close(f);
	exit(0);
}
